﻿@model PagedList<Document>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    <link href="/css/style.css" rel="stylesheet" type="text/css" />
    <link href="/css/select.css" rel="stylesheet" type="text/css" />
    <link href="/css/materialinfostyle.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="/js/jquery.js"></script>
    <script src="/js/jquery.form.js"></script>
    <script type="text/javascript" src="/js/jquery.idTabs.min.js"></script>
    <script type="text/javascript" src="/js/select-ui.min.js"></script>
    <script language="javascript">
        $(function () {
            //导航切换
            $(".imglist li").click(function () {
                $(".imglist li.selected").removeClass("selected")
                $(this).addClass("selected");
            })
        })
    </script>
    <script type="text/javascript">
        $(document).ready(function () {
            var api = {
                edit: "/commonset/DocumentNameEdit",
                del: "/commonset/DocumentNameDel"
            }
            $('#form1').attr('action', api.edit);
            $('#form2').attr('action', api.edit);

            //抄表添加
            $(".clickmaterialadd").click(function () {
                $(".tipmaterialadd").fadeIn(200);
            });

            $(".tiptopreaderfromadd a").click(function () {
                $(".tipreaderfromadd").fadeOut(200);
            });

            $(".surematerialadd").click(function () {
                $('#form1').ajaxSubmit({
                    success: function (data) {
                        if (data.Succeed) {
                            window.location.reload();
                        } else {
                            alert(data.Msg);
                        }
                    }
                })



            });

            $(".cancelmaterialadd").click(function () {
                $(".tipmaterialadd").fadeOut(100);
            });


            //抄表修改
            $(".clickmaterialmodify").click(function () {
                var count = $("input:checked").length;
                if (count < 1) {
                    alert("至少选择一项进行修改！");
                }
                else if (count > 1) {
                    alert("只能选择一项进行修改！");
                }
                else {
                    $(".tipmaterialmodify").fadeIn(200);
                    $obj = $("input:checked").parents("tr");

                    $('#form2').find("input[name='Id']").val($obj.attr("Id"));
 
                    $('#form2').find("input[name='DocumentNo']").val($obj.attr("DocumentNo"));
                    $('#form2').find("input[name='DocumentName']").val($obj.attr("DocumentName"));
                    $('#form2').find("input[name='DocumentUnit']").val($obj.attr("DocumentUnit"));
                    $('#form2').find("input[name='DocumentPrice']").val($obj.attr("DocumentPrice"));
                     

                }
            });

            $(".tiptopfromchangemodify a").click(function () {
                $(".tipfromchangemodify").fadeOut(200);
            });

            $(".surematerialmodify").click(function () {

                $('#form2').ajaxSubmit({
                    success: function (data) {
                        if (data.Succeed) {
                            window.location.reload();
                        } else {
                            alert(data.Msg);
                        }
                    }
                })


            });

            $(".cancelmaterialmodify").click(function () {
                $(".tipmaterialmodify").fadeOut(100);
            });


            //删除用户
            $(".clickdel").click(function (del) {
                var count = $("input:checked").length;
                if (count < 1) {
                    alert("至少选择一项进行删除！");
                }
                else if (count > 1) {
                    alert("只能选择一项进行修改！");
                }
                else {
                    $(".tipdel").fadeIn(200);
                }
            });

            $(".tiptopdel a").click(function (del) {
                $(".tipdel").fadeOut(200);
            });

            $(".suredel").click(function (del) {
                $obj = $("input:checked").parents("tr");
                $.post(api.del, { id: $obj.attr("Id") }, function (data) {
                    $(".tipdel").fadeOut(100);
                    window.location.reload();
                }, 'json')
            });

            $(".canceldel").click(function (del) {
                $(".tipdel").fadeOut(100);
            });

        });
    </script>
    <script type="text/javascript">
        $(document).ready(function (e) {
            $(".select1").uedSelect({
                width: 345
            });
            $(".select2").uedSelect({
                width: 167
            });
            $(".select3").uedSelect({
                width: 150
            });
        });
    </script>
</head>
<body>
    <div class="place">
        <span>位置：</span>
        <ul class="placeul">
            <li><a href="#">首页</a></li>
            <li><a href="#">基本设置管理</a></li>
            <li><a href="#">材料名称设置</a></li>
        </ul>
    </div>
    <div class="rightinfo">
        <div class="tools">
            <ul class="toolbar">
                <li class="clickmaterialadd"><span><img src="/images/t01a.png" /></span>添加</li>
                <li class="clickmaterialmodify"><span><img src="/images/t02.png" /></span>修改</li>
                <li class="clickdel"><span><img src="/images/t03.png" /></span>删除</li>

            </ul>

        </div>
        <table class="imgtable">
            <thead>
                <tr>
                    <th>选择</th>
                    <th>材料编号</th>
                    <th>材料名称</th>
                    <th>材料单位</th>
                    <th>材料价格</th>
                </tr>
            </thead>
            <tbody>
                @foreach (var item in Model)
                {
                    <tr Id="@item.Id" DocumentNo="@item.DocumentNo" DocumentName="@item.DocumentName" DocumentUnit="@item.DocumentUnit" DocumentPrice="@item.DocumentPrice">
                        <td><input name="" type="checkbox" value="@item.Id" /></td>
                        <td>@(item.DocumentNo)</td>
                        <td height="30px;">@(item.DocumentName)</td>
                        <td><a href="#">@(item.DocumentUnit)</a></td>
                        <td>@(item.DocumentPrice.ToString("f2"))</td>
                    </tr>
                }

            </tbody>
        </table>
        <div class="pagin">
            <div class="message">共<i class="blue">@(Model.TotalItemCount)</i>条记录，共&nbsp;<i class="blue">@(Model.TotalPageCount)&nbsp;</i>页</div>
            @Html.Pager(Model, BaseController.PagerOptions)
        </div>

        <form method="post" id="form1">
            <!--材料添加-->
            <div class="tipmaterialadd">
                <div class="tiptopmaterialadd"><img src="/images/t06.png" /><span>材料添加</span><a></a></div>
                <div class="tipinfomaterialadd">
                    <div class="userinfozbmaterialadd">
                        <dt class="userinfozbtitmaterialadd">材料信息</dt>
                        <ul class="seachform">
                            <li>
                                <label>材料编号</label>
                                <input name="DocumentNo" type="text" class="scinput" />
                            </li>
                            <li>
                                <label>材料名称</label>
                                <input name="DocumentName" type="text" class="scinput" />
                            </li>
                            <li>
                                <label>材料单位</label>
                                <input name="DocumentUnit" type="text" class="scinput" />
                            </li>
                            <li>
                                <label>材料单价</label>
                                <input name="DocumentPrice" type="text" class="scinput" />
                            </li>
                        </ul>
                    </div>
                </div>
                <div class="tipbtnmaterialadd">
                    <input name="" type="button" class="surematerialadd" value="添加" />
                    &nbsp;
                    <input name="" type="button" class="cancelmaterialadd" value="取消" />
                </div>
            </div>
        </form>
        <!--删除用户-->
        <div class="tipdel">
            <div class="tiptopdel"><span>提示信息</span><a></a></div>
            <div class="tipinfodel">
                <span><img src="/images/ticon01.png" /></span>
                <div class="tiprightdel">
                    <p>确定要删除选中的材料名称吗？</p>
                    <cite>如果是请点击确定按钮 ，否则请点取消。</cite>
                </div>
            </div>
            <div class="tipbtndel">
                <input name="" type="button" class="suredel" value="确定" />
                &nbsp;
                <input name="" type="button" class="canceldel" value="取消" />
            </div>
        </div>


        <form method="post" id="form2">
            <!--材料修改-->
            <div class="tipmaterialmodify">
                <div class="tiptopmaterialmodify"><img src="/images/t06.png" /><span>材料修改</span><a></a></div>
                <div class="tipinfomaterialmodify">
                    <div class="userinfozbmaterialmodify">
                        <dt class="userinfozbtitmaterialmodify">材料信息</dt>
                        <ul class="seachform">
                            <li>
                                <label>材料编号</label>
                                <input name="DocumentNo" type="text" class="scinput" />
                            </li>
                            <li>
                                <label>材料名称</label>
                                <input name="DocumentName" type="text" class="scinput" />
                            </li>
                            <li>
                                <label>材料单位</label>
                                <input name="DocumentUnit" type="text" class="scinput" />
                            </li>
                            <li>
                                <label>材料单价</label>
                                <input name="DocumentPrice" type="text" class="scinput" />
                            </li>
                        </ul>
                    </div>
                </div>

                <div class="tipbtnmaterialmodify">
                    <input type="hidden" name="Id" value="" />
                    <input name="" type="button" class="surematerialmodify" value="确定" />
                    &nbsp;
                    <input name="" type="button" class="cancelmaterialmodify" value="取消" />
                </div>
            </div>
        </form>

        <script type="text/javascript">
            $('.tablelist tbody tr:odd').addClass('odd');
        </script>
    </div>
</body>
</html>
